package com.ct.commons.config;

import com.ct.commons.interceptor.auth.AdminLoginInterceptor;
import com.ct.commons.interceptor.permission.SecurityInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 飞哥
 * @Title: 学相伴出品
 * @Description: 飞哥B站地址：https://space.bilibili.com/490711252
 * 记得关注和三连哦！
 * @Description: 我们有一个学习网站：https://www.kuangstudy.com
 * @date 2022/5/16$ 22:31$
 */
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Autowired
    private AdminLoginInterceptor adminLoginInterceptor;
    @Autowired
    private SecurityInterceptor securityInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(adminLoginInterceptor).addPathPatterns("/api/v1/**")
                .excludePathPatterns("/api/v1/login/toLogin",
                        "/api/v1/code/get");
        registry.addInterceptor(securityInterceptor).addPathPatterns("/api/v1/**")
                .excludePathPatterns("/api/v1/login/toLogin",
                        "/api/v1/login/logout",
                        "/api/v1/code/get");
    }
}
